package org.dydl.dao.system.repository;

import java.math.BigDecimal;
import java.util.List;

import org.dydl.model.system.Lossdetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface LossDetailRepository extends CrudRepository<Lossdetail, Integer>,JpaSpecificationExecutor<Lossdetail>{
	

	@Query(value = "SELECT * FROM lossdetail WHERE BOM_NO = :bomNo" ,nativeQuery = true)
	List<Lossdetail> findByBomNo(@Param("bomNo")String bomNo);
	
	/**
	 * 查询生产成品所需物料
	 * @param goodsUuid
	 * @return
	 */
	@Query(value = "SELECT NAME FROM lossdetail WHERE GOODS_UUID = :goodsUuid"  ,nativeQuery = true)
	String findNameByUuid(@Param("goodsUuid")String goodsUuid);
	@Query(value = "SELECT MODEL FROM lossdetail WHERE GOODS_UUID = :goodsUuid"  ,nativeQuery = true)
	String findModelByUuid(@Param("goodsUuid")String goodsUuid);
	@Query(value = "SELECT DEC_CM FROM lossdetail WHERE GOODS_UUID = :goodsUuid"  ,nativeQuery = true)
	BigDecimal findDeccmByUuid(@Param("goodsUuid")String goodsUuid);
}
